int main(){	
	return play();
}

int play(){
	int currentValue;
	String currentCard;
	int nextValue;
	String nextCard;
	int gameScore;
	int guess;
	
	gameScore = 0;
	shuffle();
	currentCard = draw();
	currentValue = value(currentCard);
	print("The first card is",currentCard,"with value",currentValue);
	
	while(deck())
	{
		print("Do you think the next card will be lower (0) or higher (1)?");
		guess = scan();
		while (guess*guess != guess) 
		{
			print("Please respond with 0 or 1.");
			guess = scan();
		}
		nextCard = draw();
		nextValue = value(nextCard);
		print("The next card is",nextName,"with value",nextValue);
		
		if(nextValue == currentValue)
		{
			print("The values are the same. You lose.");
			break;
		}
		else if (nextValue > currentValue) 
		{
			if (guess == 1) 
			{
			   print("Your prediction was correct.");
			   gameScore++;
			}
			else 
			{
			   print("Your prediction was incorrect.");
			   break;
			}
		}
		else 
		{
			if (guess == 0) {
			   print("Your prediction was correct.");
			   gameScore++;
			}
       		else {
       			print("Your prediction was incorrect.");
       			break;
       		}
		}
		currentCard = nextCard;
		print("The card is",currentName,"with value",currentValue);
	}
	print("The game is over.");
	print("You made",gameScore,"correct predictions.");
	return gameScore;
}